package com.yifi.service;

import java.util.List;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.yifi.common.DBHelper;
import com.yifi.common.SysUtil;

public class FileService {

	public static boolean FileAdd(List<Record> list,String dirPath,String m_id,String ctype,String cuser,String cdept)
	{
		for (Record record : list) {
			
			String fid = record.getStr("fid");
			String fname = record.getStr("fname");
			String fext = record.getStr("fext");
			String furl = record.getStr("furl");
			String fsize = record.getStr("fsize");
			String nowDate = "sysdate";
			
			String id=SysUtil.getGuid();
			int isort = DBHelper.GetInt("select max(isort) from mis_attach where m_id='" + m_id + "'") + 1;
			String sql = "insert into mis_attach(id,cdesc,cpath,cext,m_id,cupload_user, cupload_org, ckey_word,cclassification, "
					+ "dupload_date,cdoc_status,cfile_size,cfiletitle,cfull_url,isort,cdoc_type,st_flag)"
					+ " values('" + id + "','" + fname + "','" + dirPath + "','" + fext + "','" + m_id + "','" + cuser
					+ "', '" + cdept + "', '" + fid + "','1', " + nowDate + ",'1','" + fsize + "','" + fname + "','"
					+ furl + "'," + isort + ",'" + ctype + "','2')";
			
			Db.update(sql);
		}
		
		return true;
	}
}
